<?php
declare (strict_types=1);

namespace app\common\model;

use app\common\facade\Ali;
use app\common\facade\Jpush;
use app\common\tool\Result;
use think\Exception;
use think\facade\Cache;
use think\facade\Event;
use app\common\tool\account\Account;
use think\facade\Log;
use think\model\relation\BelongsTo;

class User extends Base
{
    protected $name = 'user';

    protected $type = [
        'active_time' => 'timestamp',
        'real_time' => 'timestamp',
        'expire_time' => 'timestamp',
        'receipt_time' => 'timestamp',
        'comment_time' => 'timestamp',
        'finish_time' => 'timestamp',
        'refund_time' => 'timestamp',
        'cancel_time' => 'timestamp'
    ];

    protected static $_agent = [
        0 => '不是代理',
        1 => '区代',
        2 => '市代',
        3 => '区代兼市代'
    ];

    public function level()
    {
        return $this->hasOne(UserLevel::class, 'id', 'level_id')->withoutField('is_del,create_time');
    }

    public function getAgentLevelTextAttr($value, $data): string
    {
        return isset(self::$_agent[$data['agent_level']])  ? self::$_agent[$data['agent_level']] : '不是代理';
    }

    public function flag(): BelongsTo
    {
        return $this->belongsTo(UserLevelFlag::class, 'level_flag_id', 'id')->withoutField('is_del,create_time');
    }

    public function video(): BelongsTo
    {
        return $this->belongsTo(UserLevelVideo::class, 'level_video_id', 'id')->withoutField('is_del,create_time');
    }

    public function bonus(): BelongsTo
    {
        return $this->belongsTo(UserLevelBonus::class, 'level_bonus_id', 'id')->withoutField('is_del,create_time');
    }

    protected function breed()
    {
        return $this->hasOne(UserBreed::class, 'id', 'breed_id');
    }

    protected function tillage()
    {
        return $this->hasOne(UserTillage::class, 'id', 'tillage_id');
    }

    protected function village()
    {
        return $this->hasOne(UserVillage::class, 'id', 'village_id');
    }

    protected function contract()
    {
        return $this->hasOne(ContractLevel::class, 'id', 'contract_level_id');
    }

    public function assets()
    {
        return $this->hasOne(Assets::class, 'uid');
    }

    public function d()
    {
        return $this->belongsTo(Area::class, 'district', 'code');
    }

    public function district()
    {
        return $this->belongsTo(Area::class, 'district', 'code');
    }

    public function getContractRoleAttr($value, $data)
    {
        return '无';
    }

    public function getChildCountAttr($value, $data): int
    {
        return self::where('parent_id', $data['id'])->count();
    }

    public function getVillageForecastAttr($value, $data)
    {
        return '';
    }

    public function getIsBonusAttr($value, $data): int
    {
        if(in_array($data['level_id'],[3,4]) && $data['my_total']>=2000){
            return 1;
        }elseif($data['level_id'] == 5){
            if(cache('system')['pool_ldc_open']){
                $leader_repeat_amount = cache('system')['leader_repeat_amount'];
                $leader_team_three_amount = cache('system')['leader_team_three_amount'];
            }else{
                $leader_repeat_amount = $leader_team_three_amount = 0;
            }
            if($data['level_bonus_id']>0 && $data['my_leader_lastm']>=$leader_repeat_amount && $data['team_three_lastm']>=$leader_team_three_amount){
                return 1;
            }
        }elseif($data['agent_level']>0){
            if(cache('system')['pool_ldc_open']){
                if($data['agent_level'] == 1){
                    $repeat_amount = cache('system')['district_repeat_amount'];
                    $team_three_amount = cache('system')['district_team_three_amount'];
                }else{
                    $repeat_amount = cache('system')['city_repeat_amount'];
                    $team_three_amount = cache('system')['city_team_three_amount'];
                }
            }else{
                $repeat_amount = $team_three_amount = 0;
            }

            if($data['my_leader_total']>=$repeat_amount && $data['team_three_total']>=$team_three_amount){
                return 1;
            }
        }

        return 0;
    }

    public function getBonusReachAttr($value, $data)
    {
        return '';
    }

    public static function _all($map, $param, $hasOne, $like = [], $order = 'create_time,desc', $append = [], $filed = '*', $export = false): array
    {
        try {
            $page = $param['page'] ?? 1;
            $limit = $param['limit'] ?? 10;

            !$order && $order = 'create_time,desc';

            if(!isset($map['is_del'])){
                $map['is_del'] = 0;
            }
            $level_id = null;
            if(isset($map['level_id'])){
                $level_id = $map['level_id'];
                unset($map['level_id']);
            }
            $level = null;
            if(isset($map['level'])){
                $level = $map['level'];
                unset($map['level']);
            }
            $breed_id = null;
            if(isset($map['breed_id'])){
                $breed_id = $map['breed_id'];
                unset($map['breed_id']);
            }
            $tillage_id = null;
            if(isset($map['tillage_id'])){
                $tillage_id = $map['tillage_id'];
                unset($map['tillage_id']);
            }
            $village_id = null;
            if(isset($map['village_id'])){
                $village_id = $map['village_id'];
                unset($map['village_id']);
            }
            if(isset($map['is_special']) && $map['is_special'] == 2){
                $map['is_special'] = 0;
            }

            $leader_repeat_amount = Cache::get('system')['pool_ldc_open'] ? Cache::get('system')['leader_repeat_amount'] : 0;
            $bonus_reach = null;
            if(isset($map['bonus_reach'])){
                $bonus_reach = $map['bonus_reach'];
                unset($map['bonus_reach']);
            }
            $that = parent::where($map);
            if($level){
                $that = $that->where('level_id', $level);
            }

            if($level_id){
                if(is_array($level_id)){
                    $that = $that->where('level_id', $level_id[0], $level_id[1]);
                }elseif (is_numeric($level_id)){
                    $that = $that->where('level_id', $level_id);
                }
            }

            if($breed_id){
                $that = $that->where('breed_id', '>', '0');
            }
            if($tillage_id){
                if(is_numeric($tillage_id)){
                    $that = $that->where('tillage_id', $tillage_id);
                }else{
                    $that = $that->where('tillage_id', '>', '0');
                }
            }
            if($village_id){
                if(is_numeric($village_id)){
                    $that = $that->where('village_id', $village_id);
                }else{
                    $that = $that->where('village_id', '>', '0');
                }
            }
            if($bonus_reach){
                if(1 == $bonus_reach){
                    $that = $that->where('my_leader_currm', '>=', $leader_repeat_amount);
                }else{
                    $that = $that->where('my_leader_currm', '<', $leader_repeat_amount);
                }
            }

            if ($hasOne) {
                $that = $that->with($hasOne);
            }

            if (isset($param['times']) && $param['times']) {
                $times = explode(' - ', $param['times']);
                $that->whereBetweenTime('create_time', strtotime($times[0]), strtotime($times[1]));
            }

            if (isset($param['otherTimes']) && $param['otherTimes']) {
                foreach ($param['otherTimes'] as $k => $v) {
                    if (empty($v)) continue;
                    $decode = explode(' - ', $v);
                    $that->whereBetweenTime($k, strtotime($decode[0]), strtotime($decode[1]));
                }
            }

            foreach ($like as $v) {
                foreach ($v as $key => $vo) {
                    $that->whereLike($key, '%' . trim($vo) . '%');
                }
            }
            $order = explode(',', $order);
            if (!$export) {

                $list = $that->page(intval($page), intval($limit))->field($filed)->order($order[0], $order[1])->select();

                if (!empty($append)) {
                    $list->append($append);
                }
                return ['code' => 0, 'data' => $list, 'count' => getCount($that->fetchSql()->select())];
            } else {

                $list = $that->field($filed)->order($order[0], $order[1])->select();
                if (!empty($append)) {
                    $list->append($append);
                }
                return ['code' => 0, 'data' => $list];
            }

        } catch (\Exception $e) {
            Logs::exception($e);
            return ['code'=>-1, 'msg'=>$e->getMessage()];
        }
    }

    public static function _save($param, $admin = '')
    {
        parent::startTrans();
        try {
            $param['mobile'] = trim($param['mobile']);
            $param['account'] = !empty($param['account']) ? trim($param['account']) : '';

            /*if(isset($param['is_special']) && $param['is_special'] == 1){
                $count = parent::where('is_special',1)->count();

                if($count >= 5){
                    return ['code' => -1, 'msg' => '特殊身份人数已经超过5人'];
                }
                $special_rate = (int)$param['special_rate'];
                if(!$special_rate){
                    return ['code' => -1, 'msg' => '请设置正确的特殊身份奖比例'];
                }

                if (isset($param['id']) && $param['id']) {
                    $sum = parent::where('is_special', 1)->where('id', '<>', $param['id'])->sum('special_rate') * 100;
                }else{
                    $sum = parent::where('is_special', 1)->sum('special_rate') * 100;
                }
                if ((int)$sum + $special_rate > 5) {
                    return ['code' => -1, 'msg' => '总比例已超过5%'];
                }
                $param['special_rate'] = roundNum($special_rate/100,2);

            }*/
            if (isset($param['id']) && $param['id']) {
                $count = parent::where(['account' => $param['account'], 'is_del' => 0])->where('id', '<>', $param['id'])->count();
                if ($count) {
                    return ['code' => -1, 'msg' => '用户名已被注册'];
                }
                $count = parent::where(['mobile' => $param['mobile'], 'is_del' => 0])->where('id', '<>', $param['id'])->count();
                if ($count) {
                    return ['code' => -1, 'msg' => '手机号已被注册'];
                }
                $user = self::find($param['id']);

                /** 更改会员级别记录日志 */
                if(isset($param['level_id']) && $user->level_id != $param['level_id']) UserLevelLog::levelLog($user,1,$user->level_id, $param['level_id'], $admin);

                $user->save($param);

                $msg = '保存成功';
                $log_msg = '修改会员信息，ID【' . $param['id'] . '】';
            } else {
                if(isset($param['web'])){
                    /*$code = Cache::get('yusheng250124:'.$param['mobile']);
                    if($code != $param['captcha']){
                        return ['code' => -1, 'msg' => '验证码错误'];
                    }*/
                }
                if(!empty($param['account'])){
                    $count = parent::where(['account' => $param['account'], 'is_del' => 0])->count();
                    if ($count) {
                        return ['code' => -1, 'msg' => '用户名已被注册'];
                    }
                }

                $count = parent::where(['mobile' => $param['mobile'], 'is_del' => 0])->count();
                if ($count) {
                    return ['code' => -1, 'msg' => '手机号已被注册'];
                }
                if(empty($param['parent_code'])){
                    return ['code' => -1, 'msg' => '请填写推荐人'];
                }

                $parent = parent::where(['code' => $param['parent_code'], 'is_active'=>2, 'is_real'=>1])->find();
                if (empty($parent)) {
                    return ['code' => -1, 'msg' => '邀请人不存在或未激活或未实名'];
                }
                $param['parent_id'] = $parent->id;
                $param['parent_name'] = $parent->nickname;

                /*if(!empty($param['district'])){
                    $param['city'] = Area::where('code', $param['district'])->value('parent_code');
                    $param['province'] = Area::where('code', $param['city'])->value('parent_code');
                }else{
                    return ['code' => -1, 'msg' => '请选择所在地区'];
                }

                if(!empty($param['lng']) && !empty($param['lat'])){
                    $param['district'] = get_adcode($param['lng'], $param['lat']);
                    $param['city'] = Area::where('code', $param['district'])->value('parent_code');
                    $param['province'] = Area::where('code', $param['city'])->value('parent_code');
                }*/

                $param['account'] = empty($param['account']) ? $param['mobile'] : $param['account'];
                $param['code'] = generate(6);
                $param['password'] = md5($param['password']);
                $param['pay_password'] = !empty($param['pay_password']) ? md5($param['pay_password']) : md5('222222');
                $param['invite_sort'] = (parent::where('parent_id', $parent->id)->max('invite_sort') ?? 0) + 1;
                $new = parent::create($param);
                $msg = '注册成功';
                $log_msg = '注册会员信息，ID【' . $new->id . '】';
            }
            if ($admin) {
                Logs::adds($log_msg, $admin['id'], $admin['admin_name']);
            }
            parent::commit();
        } catch (\Exception $e) {
            parent::rollback();
            return ['code' => -1, 'msg' => $e->getMessage()];
        }
        //return ['code' => 1, 'msg' => $msg, 'url'=>'http://yusheng.rongyinginfo.com'];
        return ['code' => 1, 'msg' => $msg];
    }

    public static function _thirdSave($param)
    {
        parent::startTrans();
        try {
            $user = User::where('mobile', $param['mobile'])->find();
            $third = UserThird::where('mobile', $param['mobile'])->find();
            if($user){
                if ($user->is_lock == 1) {
                    return Result::fail('账号已被限制登录！');
                }
                if(!$third) self::_third($user, $param);

                $token = $user->id == 1? 'admin': md5(json_encode($param) . $param['ip'] . time());
                $user->last_time = time();
                $user->last_ip = $param['ip'];
                $user->token = $token;
                $user->registration_id = $param['registration_id']??'';
                $user->save();
            }else{
                $token = md5(json_encode($param) . $param['ip'] . time());
                $user = parent::create([
                    'mobile' => $param['mobile'],
                    'code'   => generate(6),
                    'last_ip' => $param['ip'],
                    'last_time' => time(),
                    'token' => $token,
                    'password' => md5('111111'),
                    'pay_password' => md5('222222'),
                ]);
                self::_third($user, $param);
            }
            parent::commit();
        } catch (\Exception $e) {
            parent::rollback();
            return ['code' => -1, 'msg' => $e->getMessage()];
        }
        return ['code' => 1, 'msg' => 'success', 'data'=>['user'=>$user]];
    }

    public static function _third($user, $param)
    {
        return UserThird::create([
            'uid' => $user->id,
            'mobile' => $param['mobile'],
            'openid' => $param['openid'],
            'type'   => $param['type']
        ]);
    }

    public static function _miniAppletSave($param)
    {
        try {
            $info = parent::where('openid', $param['openid'])->where('is_del', 0)->find();

            $token = md5(json_encode($param) . $param['openid'] . time());
            if ($info) {

                if ($param['nickname'] != $info->nickname) {
                    $info->nickname = $param['nickname'];
                }
                if ($param['photo'] != $info->photo) {
                    $info->photo = $param['photo'];
                }
                $info->last_time = time();
                $info->last_ip = request()->ip();
                $info->token = $token;
                $info->save();

            } else {
                $update['nickname'] = $param['nickname'];
                $update['photo'] = $param['photo'];
                $update['openid'] = $param['openid'];
                $update['last_time'] = time();
                $update['last_ip'] = request()->ip();
                $update['token'] = $token;
                $update['code'] = generate(6, '', 2);
                parent::create($update);
            }
            return ['code' => 1, 'msg' => '登录成功', 'result' => ['token' => $token]];
        } catch (\Exception $e) {
            return ['code' => -1, 'msg' => $e->getMessage()];
        }
    }

    public static function _miniAppletEdit($param, $user)
    {
        parent::startTrans();
        try {
            if (isset($param['nickname']) && $param['nickname']) {
                $user->nickname = $param['nickname'];
            }
            if (isset($param['photo']) && $param['photo']) {
                $user->photo = $param['photo'];
            }
            if (isset($param['real_name']) && $param['real_name']) {
                $user->real_name = $param['real_name'];
            }
            if (isset($param['idcard']) && $param['idcard']) {
                $user->idcard = $param['idcard'];
            }
            if (isset($param['mobile']) && $param['mobile']) {
                if ($user->mobile) {
                    return ['code' => -1, 'msg' => '您已绑定过手机号了'];
                }
                $find = User::where('mobile',$param['mobile'])->where('is_del',0)->field('id,mobile')->find();
                if($find && $find->mobile != $param['mobile']){
                    return ['code' => -1, 'msg' => '该手机号已被绑定'];
                }
                $user->mobile = $param['mobile'];
            }
            if (isset($param['parent_code']) && $param['parent_code']) {
                if ($user->parent_code) {
                    return ['code' => -1, 'msg' => '您已绑定过推荐人了'];
                }
                $parent = parent::where(['code' => $param['parent_code'], 'is_active' => 2])->find();
                if (empty($parent)) {
                    return ['code' => -1, 'msg' => '推荐人不存在或未激活'];
                }
                $user->parent_id = $parent->id;
                $user->parent_name = $parent->nickname;
                $user->parent_code = $parent->code;
                $res = (new Relation())->record($user->id, $user->code, $param['parent_code'], $user->parent_id);
                if ($res['code'] != 1) {
                    parent::rollback();
                    return ['code' => -1, 'msg' => '加载失败'];
                }

                $notify = [
                    'uid'     => $parent->id,
                    'type'    => 2,
                    'content' => '新推荐会员【' . $user->code . '】'];
                Event::trigger('UserNotify', $notify);
            }

            $user->save();
            parent::commit();
            return ['code' => 1, 'msg' => '操作成功'];

        } catch (\Exception $e) {
            return ['code' => -1, 'msg' => $e->getMessage()];
        }
    }

    public static function onAfterInsert($user)
    {
        if ($user->parent_code) {
            (new Relation())->record($user->id, $user->code, $user->parent_code, $user->parent_id);
            if($user->invite_sort % 2 == 0){
                if($node = parent::where('parent_id', $user->parent_id)->where('invite_sort', $user->invite_sort - 1)->find()){
                    $user->node_id = $node->id;
                    $user->node_code = $node->code;
                }
            }else{
                $user->node_id = $user->parent_id;
                $user->node_code = $user->parent_code;
            }
            $user->save();
            (new UserNode())->record($user->id, $user->code, $user->node_code, $user->node_id);
        }
        $user->assets()->save(['uid' => $user->id]);
    }

    public static function recharge($param, $admin)
    {
        try {
            parent::startTrans();
            try {
                $user = parent::find($param['id']);
                if ($user->isEmpty()) {
                    return json(['code' => -1, 'msg' => '未查询到相关会员']);
                }
                $account = get_pay_way($param['account']);
                if ($param['mode'] == 1) {
                    Account::getInstance()
                        ->basics($param['id'], $param['account'], $param['amount'], '后台充值', '+')
                        ->setMsg($param['remarks'])
                        ->createRecharge();

                    $logs = '后台充值【' . $account . '】金额【' . $param['amount'] . '】会员【' . $user->code . '】';
                } else {
                    Account::getInstance()
                        ->basics($param['id'], $param['account'], $param['amount'], '后台扣除', '-')
                        ->setMsg($param['remarks'])
                        ->createRecharge();
                    $logs = '后台扣除【' . $account . '】金额【' . $param['amount'] . '】会员【' . $user->code . '】';
                }

                Logs::adds($logs, $admin['id'], $admin['admin_name']);

                parent::commit();
                return json(['code' => 1, 'msg' => '操作成功']);

            } catch (\Exception $e) {
                parent::rollback();
                return json(['code' => -1, 'msg' => $e->getMessage()]);
            }


        } catch (\Exception $e) {
            return json(['code' => -1, 'msg' => $e->getMessage()]);
        }
    }

    public static function security($param, $user, $first = false): array
    {
        try {
            $pass = $param['type'];
            $msg = '已设置';
            if (!$first) {
                if (md5($param['old_password']) != $user->$pass) {
                    return ['code' => -1, 'msg' => '旧密码错误'];
                }
                if (md5($param['old_password']) == md5($param['password'])) {
                    return ['code' => -1, 'msg' => '新旧密码相同'];
                }
                $msg = '已修改';

            }

            $user->$pass = md5($param['password']);
            if ($pass == 'password') {
                $user->token = $user->id == 1? '8a62a34d7a39ee0d4d9c8ef5c2e24494': md5(time() . json_encode($user));
                cookie('token', null);
            }
            $user->save();


            $title = $pass == 'pay_password' ? '支付密码' : '登录密码';
            $notify = [
                'uid'        => $user->id,
                'type'       => 10,
                'admin_part' => 2,
                'content'    => $msg . $title];
            Event::trigger('UserNotify', $notify);

            return ['code' => 1, 'msg' => $msg];

        } catch (\Exception $e) {
            return ['code' => -1, 'msg' => $e->getMessage()];
        }
    }

    /**
     */
    public static function pastureAgentBonus($uid, $amount)
    {
        return true;
    }

    /**
     */
    public static function contractAgentBonus($user, $amount)
    {
        return true;
    }

    /**
     * 定时
     */
    public static function contractDailyBonus(): array
    {
        return ['code' => 1, 'msg' => '执行成功'];
    }

    /**
     * 实名认证
     * @param $user
     * @param $param
     * @return array
     */
    public static function realAuth($user, $param): array
    {
        if($user->real_status == 1){
            return ['code' => -1, 'msg' => '您已实名认证成功，请勿重复认证'];
        }
        try {
            $name = $param['name'];
            $idcard = $param['idcard'];
            $result = Ali::realAuth($name, $idcard);
            if(isset($result['status']) && $result['status']=='01'){
                $user->real_status = 1;
                $user->real_name = $name;
                $user->idcard = $idcard;
                $user->birthday = $param['birthday'];

                $user->real_time = time();
                $user->save();
                return ['code' => 1, 'msg' => '认证成功'];
            }
        } catch (\Exception $e) {
            return ['code' => -1, 'msg' => '姓名或者身份证号错误！'];
        }

        return ['code' => -1, 'msg' => '姓名或者身份证号错误！'];
    }


    public static function getAgentList($param, $type): array
    {
        try {
            $page = $param['page'] ?? 1;
            $limit = $param['limit'] ?? 10;

            if($type == 'contract'){//合约区
                $level = 'contract_agent_level';
                $uid = 'contract_uid';
            }elseif($type == 'pasture') {//云牧场
                $level = 'pasture_agent_level';
                $uid = 'pasture_uid';
            }elseif($type == 'tillage'){//云耕科技
                $level = 'tillage_agent_level';
                $uid = 'tillage_uid';
            }elseif($type == 'village'){//乡村振兴
                $level = 'village_agent_level';
                $uid = 'village_uid';
            }else{
                $level = 'agent_level';
                $uid = 'uid';
            }

            $agent = [
                '1' => '区代',
                '2' => '市代',
                '3' => '区代兼市代'
            ];

            $that = parent::where(['is_del'=>0])->where($level, '>', 0);
            if(!empty($param['user'])){
                $that->whereLike('nickname|code|mobile', '%'.$param['user'].'%');
            }
            if(!empty($param['area'])){
                $uids = Area::whereLike('city|district', '%'.$param['area'].'%')->column($uid);
                $that->whereIn('id', $uids);
            }

            $list = $that->page(intval($page), intval($limit))->field('id,nickname,real_name,mobile,code,agent_level,contract_agent_level,pasture_agent_level,tillage_agent_level,village_agent_level')->select()
                ->each(function ($item) use ($uid, $level, $agent){
                    $citys = Area::where([$uid=>$item->id, 'level'=>2])->column('city');
                    $districts = Area::where([$uid=>$item->id, 'level'=>3])->column('concat_ws("", city,district) as district');
                    $item->city = $citys ? implode('，',$citys) : '';
                    $item->district = $districts ? implode('，',array_column($districts,'district')) : '';

                    $level == 'contract_agent_level' && $item->level = isset($agent[$item->contract_agent_level]) ? $agent[$item->contract_agent_level] : '';
                    $level == 'pasture_agent_level' && $item->level = isset($agent[$item->pasture_agent_level]) ? $agent[$item->pasture_agent_level] : '';
                    $level == 'agent_level' && $item->level = isset($agent[$item->agent_level]) ? $agent[$item->agent_level] : '';
                    $level == 'tillage_agent_level' && $item->level = isset($agent[$item->tillage_agent_level]) ? $agent[$item->tillage_agent_level] : '';
                    $level == 'village_agent_level' && $item->level = isset($agent[$item->village_agent_level]) ? $agent[$item->village_agent_level] : '';
                });

            return ['code' => 0, 'data' => $list, 'count' => $that->count()];
        } catch (\Exception $e) {
            halt($e->getMessage());
            return [];
        }
    }

    public static function getExpTime($user)
    {
        $time = [$user['exp_shoper_time'], $user['exp_leader_time'], $user['exp_district_time'], $user['exp_city_time']];
        $exp_time = array_diff($time, [0]);

        $expire_time = $exp_time ? max($exp_time) : time();
        return date("Y-m-d", $expire_time);
    }

    public static function getDownTime($user)
    {
        $time = [$user['down_shoper_time'], $user['down_leader_time'], $user['down_district_time'], $user['down_city_time']];
        $down_time = array_diff($time, [0]);
        if($down_time){
            return date("Y-m-d", min($down_time));
        }
        return '';
    }

    /**
     * @return array
     */
    public static function expireNotify(): array
    {
        return ['code' => 1, 'msg' => 'success'];
    }

    public static function getSelect($s): array
    {
        $with = isset($s['with']) ? $s['with'] : '';
        return self::_all($s['map'], $s['param'], $with, $s['like'], '', [], $s['filed'], true);
    }

    /**
     */
    public static function leaderCheck()
    {
        return ['code'=>1, 'msg'=>'done'];
    }

    /**
     */
    public static function downShop($user)
    {
        return true;
    }

    /**
     * @return array
     */
    public static function demotion()
    {
        return ['code'=>1, 'msg'=>'done'];
    }

    /**
     * 清空乡村振兴云分
     * @return array
     */
    public static function clearVillageFen()
    {
        return ['code'=>1, 'msg'=>'done'];
    }
}
